package com.th.therp.mapper;

import com.th.therp.pojo.emtity.MaterialCategory;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MaterialCategoryMapper {

    //查找全部商品分类
    @Select("select * from material_category where is_deleted=0")
    List<MaterialCategory> list();

    //新增商品分类
    @Insert("insert into material_category (name,is_deleted) values (#{name},0)")
    void add(MaterialCategory materialCategory);

    void update(MaterialCategory materialCategory);

    //根据id查找分类名称
    @Select("select name from material_category where id=#{categoryId}")
    String findCategoryNameById(Integer categoryId);

    //根据名称查询商品分类
    @Select("select * from material_category where name=#{name} and is_deleted=0")
    MaterialCategory findByName(String name);
}